<?php
/* 
 * Copyright (c) 2018-{{Y}}   All rights reserved.
 *
 * 创建时间：{{$YmdHi}}
 *
 * 项目：{{$classdir}}/levcc  -  $  - Form_mynameHelper.php
 *
 * 作者：{{AUTO GENERATE}}
 */

//此文件使用程序自动生成，下次生成时【不会】覆盖。
//在这里可以补充、完善你的程序逻辑

namespace modules\levcc\table\form\Form_myname;

use Lev;
use lev\widgets\inputs\tablesForm;
use modules\levcc\table\form\Form_myname\_gen\BaseForm_myname;

!defined('INLEV') && exit('Access Denied LEV');

class BaseForm_mynameMiddle extends BaseForm_myname
{

    public static $tableName = '{{$tableName}}';
    public static $formPre = 'datax';

    public static function saveForm($formPre = 'datax', $route = '', $form = null, $upData = null, $upDataForce = null, $opInfo = null)
    {
        if ($formPre) {
            static::$formPre = $formPre;
        }else {
            $formPre = static::$formPre;
        }

        $upData === null &&
        $upData = Lev::stripTags(Lev::POSTv($formPre));

        $opid = intval(Lev::GPv('opid'));

        $opInfo === null &&
        $opInfo = $opid >0 ? static::findOne(['id'=>$opid]) : [];

        return parent::saveForm($formPre, $route, $form, $upData, $upDataForce, $opInfo); // TODO: Change the autogenerated stub
    }

    public static function saveFormCall($upData, $opInfo = [], $upDataForce = null, $route = '', $form = null) {
        return static::saveForm('', $route, $form, $upData, $upDataForce, $opInfo);
    }

    /**
     * 额外的表单字段，不会存入数据库
     * @return array
     */
    public static function extInputs()
    {
        return parent::extInputs(); // TODO: Change the autogenerated stub
    }

    public static function headerHtm()
    {
        $htm = '<style>.formFieldBox .checkBoxStrValue {display: block !important;}</style>';
        $htm.= parent::headerHtm(); // TODO: Change the autogenerated stub
        return $htm;
        //return '<tips class="gray inblk scale8">自定义headerHtm：文件位置：'.__DIR__ . '/Form_myname.php'.'</tips>';
    }

    public static function footerHtm()
    {
        return parent::footerHtm(); // TODO: Change the autogenerated stub
        //return '<tips class="gray inblk scale8">自定义footerHtm</tips>';
    }

    public static function footerFormInnerHtm()
    {
        return parent::footerFormInnerHtm(); // TODO: Change the autogenerated stub
        //return '<tips class="gray inblk scale8">自定义footerFormInnerHtm</tips>';
    }

    /**
     * 数据统计，
     */
    public static function statisticsv($modalObject = null, $where = ['tstatus' => 0], $update = ['tstatus' => 1], $limit = 2000, $astatusField = 'astatus', $totalsField = 'score', $totalswinField = 'awardscore', $totalnumField = '', $totalwinnumField = '', $field = '*')
    {
        //$modalObject === null &&
        //$modalObject = 'modules\levs\modules\ipban\table\ipban_record\ipbanRecordModelHelper';
        //$field === '*' &&
        //$field = 'id,pagename,ip,uid,iden,iptotal,pagetotal,tstatus,status,addtime';
        return parent::statisticsv($modalObject, $where, $update, $limit, $astatusField, $totalsField, $totalswinField, $totalnumField, $totalwinnumField, $field); // TODO: Change the autogenerated stub
    }
}


class Form_myname extends BaseForm_mynameMiddle {

    public static function allColumns()
    {
        return parent::allColumns(); // TODO: Change the autogenerated stub
    }

    public static function safeColumnsInpus($columns)
    {
        return parent::safeColumnsInpus($columns); // TODO: Change the autogenerated stub
    }

    /**
     * 数据类型转化，在自动生成的控制器中自行实现
     * @param $upData
     * @param bool $save 为真时，入库保存；为假时，出库显示
     * @return mixed
     */
    public static function formatUpdata($upData, $save = true)
    {
        $checkboxs = Lev::stripTags(Lev::GPv('checkboxs_'.static::$formPre));
        $checkboxsTableFormv = Lev::stripTags(Lev::GPv('checkboxs_'.tablesForm::getFormPre()));
//        if ($save) {
//            isset($upData['comrate']) &&
//            $upData['comrate'] = round($upData['comrate'] * 1000);
//        }else {
//            isset($upData['comrate']) &&
//            $upData['comrate'] /= 1000;
//        }
        return parent::formatUpdata($upData, $save); // TODO: Change the autogenerated stub
    }

    public static function setFormSettings($settings, $result = [])
    {
        return parent::setFormSettings($settings, $result); // TODO: Change the autogenerated stub
    }

    public static function saveInputs($datas, $where = [], $inId = false, $tables = [], $inputs = [], $formSet = true, $tablesFormData = [])
    {
        return parent::saveInputs($datas, $where, $inId, $tables, $inputs, $formSet, $tablesFormData); // TODO: Change the autogenerated stub
    }

    public static function getNextSetup()
    {
        return parent::getNextSetup(); // TODO: Change the autogenerated stub
    }

    public static function inputsSetup()
    {
        return parent::inputsSetup(); // TODO: Change the autogenerated stub
    }

    public static function setupDesc()
    {
        return parent::setupDesc(); // TODO: Change the autogenerated stub
    }

}